﻿using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.UI;

namespace Terraria.GameContent.UI.Elements
{
	// Token: 0x020003F8 RID: 1016
	public class UIProgressBar : UIElement
	{
		// Token: 0x060023C1 RID: 9153 RVA: 0x0001944C File Offset: 0x0001764C
		public UIProgressBar()
		{
			this._progressBar.Height.Precent = 1f;
			this._progressBar.Recalculate();
			base.Append(this._progressBar);
		}

		// Token: 0x060023C2 RID: 9154 RVA: 0x0001948B File Offset: 0x0001768B
		public void SetProgress(float value)
		{
			this._targetProgress = value;
			if (value < this._visualProgress)
			{
				this._visualProgress = value;
			}
		}

		// Token: 0x060023C3 RID: 9155 RVA: 0x0047A590 File Offset: 0x00478790
		protected override void DrawSelf(SpriteBatch spriteBatch)
		{
			this._visualProgress = this._visualProgress * 0.95f + 0.05f * this._targetProgress;
			this._progressBar.Width.Precent = this._visualProgress;
			this._progressBar.Recalculate();
		}

		// Token: 0x04003FF2 RID: 16370
		private UIProgressBar.UIInnerProgressBar _progressBar = new UIProgressBar.UIInnerProgressBar();

		// Token: 0x04003FF3 RID: 16371
		private float _visualProgress;

		// Token: 0x04003FF4 RID: 16372
		private float _targetProgress;

		// Token: 0x020003F9 RID: 1017
		private class UIInnerProgressBar : UIElement
		{
			// Token: 0x060023C4 RID: 9156 RVA: 0x0047A5E0 File Offset: 0x004787E0
			protected override void DrawSelf(SpriteBatch spriteBatch)
			{
				CalculatedStyle dimensions = base.GetDimensions();
				spriteBatch.Draw(Main.magicPixel, new Vector2(dimensions.X, dimensions.Y), null, Color.Blue, 0f, Vector2.Zero, new Vector2(dimensions.Width, dimensions.Height / 1000f), SpriteEffects.None, 0f);
			}
		}
	}
}
